package ltd.hanamaki.selenium.study.studySelenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.List;
import java.util.Set;

/**
 * @author : FHM
 * @data : 2021/9/3 - 10:56
 */
public class Demo05 {



    static WebDriver driver;
    static Navigation navigate;

    @BeforeClass
    public void setUp() {
        /* 3.1.  */
        /* 注册 火狐浏览器打开的位置 */
        System.setProperty("webdriver.gecko.driver", "C:\\Program Files\\Mozilla Firefox\\geckodriver.exe");
        /* 3.2 注册 驱动 */
        driver = new FirefoxDriver();

        /* 实例化 导航对象 */
        navigate = driver.navigate();
    }

    @Test
    public void t() throws InterruptedException {

        driver.get("file:///C:/Users/86130/Desktop/testhtml/exam/index.html");

        /* 点击 继续 提供房源信息 */
        driver.findElement(By.linkText("继续提供房源信息")).click();

        /* 获得 所有的窗口的  句柄 */
        Set<String> windowHandles = driver.getWindowHandles();
        System.out.println(windowHandles);

        /* 将 集合转换为 数组 */
        Object[] objects = windowHandles.toArray();

        /* 切换  句柄*/
        driver.switchTo().window(String.valueOf(objects[1]));


        /* 点击  720 */
        driver.findElement(By.xpath("//input[@name='c2']")).click();



//        driver.switchTo().

    }



}
